function frame = WiSiL_Frame_removeRefSymb( signalrx, modulation, ...
                                            frameParam, transmitter )
% WISIL_FRAME_REMOVEREFSYMB Remove reference symbols from a frame.
%
%  FRAME = WiSiL_Frame_removeRefSymb( SIGNAL_RX, MODULATION, FRAMEPARAM,
%  TRANSMITTER ) remove LLR values which correspond to reference signals
%  and zeros from the received signal SIGNAL_RX and returns the resulting 
%  data signal in FRAME, according to the parameters in MODULATION,
%  FRAMEPARAM and TRANSMITTER.

% History:
% Erika Portela, 14/Jul/2008
%   Insert structure frame, transmitter and modulation

% For frame Type 1 with normal cyclic prefix and 2 antennas,
% reference signals are mapped into OFDM Symbols 0 and 4. For 4 antennas
% reference signals are mapped into OFDM Symbols 0,1 and 4.

% 14/07/2008
% Erika Portela
% 
wordSize = log2( modulation.M );

sizeSlot = frameParam.N_RB_SC * frameParam.N_DL_RB * ...
            frameParam.N_DL_Symb*wordSize;
frame = [];

nBits = frameParam.N_DL_RB * frameParam.N_RB_SC * wordSize;
    
for slot = 1:20
    
    symbSlot = signalrx(1:sizeSlot);
    signalrx = signalrx(sizeSlot+1:end);
    
    for symbol = 1:frameParam.N_DL_Symb
      
        if(symbol == 1) || (symbol == 5)
            symb = symbSlot( 1 : nBits);
            symbSlot = symbSlot( nBits + 1 : end );
            for RB = 1 : frameParam.N_DL_RB
                symb_RB = symb( 1 : frameParam.N_RB_SC * wordSize );
                symb = symb( frameParam.N_RB_SC * wordSize + 1: end);
                
                if (transmitter.txNum == 1 || transmitter.txNum == 2) 
                    switch symbol
                        case 1
                            frame = [ frame symb_RB(wordSize+1:6*wordSize) ...
                                      symb_RB(7*wordSize+1:12*wordSize)];
                        case 5
                            frame = [frame symb_RB(1:3*wordSize) ...
                                     symb_RB(4*wordSize+1:9*wordSize)...
                                     symb_RB(10*wordSize+1:12*wordSize) ];
                    end
                end
            end
        else
            symb = symbSlot(1: nBits);
            symbSlot = symbSlot( nBits + 1 : end );
            frame = horzcat(frame,symb);      
        end
    end
end

